package vn.ivs.taxiapp.adapters;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;

import vn.ivs.taxiapp.R;
import vn.ivs.taxiapp.models.Bookmark;
import vn.ivs.taxiapp.models.TaxiInfo;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class S006ListViewAdapter extends ArrayAdapter<Bookmark> {
	private ArrayList<Bookmark> mBookmarkList;
	private Context context;
	private TextView mTvName;
	private TextView mTvDate;

	public S006ListViewAdapter(Context context, ArrayList<Bookmark> listOb) {
		super(context, R.layout.s006_item_view, listOb);
		this.context = context;
		this.mBookmarkList = listOb;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.s006_item_view, parent, false);
		mTvName = (TextView) rowView.findViewById(R.id.s006_item_view_name);
		mTvDate = (TextView) rowView.findViewById(R.id.s006_item_view_date);

		mTvName.setText(mBookmarkList.get(position).getName());

		// Set current date
		Calendar calendar = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd",
				Locale.getDefault());
		String dateStr = sdf.format(calendar.getTime());
		mTvDate.setText(dateStr);
		return rowView;
	}
}
